package cn.edu.scau.cmi.chenjia.client;

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Group;
import javafx.scene.control.TextField;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
import cn.edu.scau.cmi.chenjia.singleton.ChairMan;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Paint;

public class SingletonClient extends Application{
	 public static void main( String[] args)
	    {
	        launch(args);
	    }
	 @Override 
	    public void start(Stage primaryStage) {  
		 	primaryStage.setTitle("Singleton"); 
		 	
		 	TextField tf1=new TextField();
		 	tf1.setLayoutX(257); 
			tf1.setLayoutY(100);	
			tf1.setPrefWidth(300);
			tf1.setPrefHeight(30);
			
			TextField tf2=new TextField();
		 	tf2.setLayoutX(0); 
			tf2.setLayoutY(150);	
			tf2.setPrefWidth(656);
			tf2.setPrefHeight(401);
			
		 	Button button = new Button("Establish");
			button.setLayoutX(558); 
			button.setLayoutY(100);	
			button.setPrefWidth(100);
			button.setPrefHeight(30);
			
			Label lb=new Label("Please enter the Chairman's name:");
			lb.setLayoutX(10); 
			lb.setLayoutY(100);	
			lb.setPrefWidth(250);
			lb.setPrefHeight(30);
					
			Group group = new Group();
			group.getChildren().add(button);
			group.getChildren().add(tf1);
			group.getChildren().add(tf2);
			group.getChildren().add(lb);
			
			button.setOnMouseClicked(e->{
				String name = tf1.getText();
				ChairMan chairman = ChairMan.getInstance(name);
				tf2.setText(name + chairman.toString());	
			});
			
			
			Scene scene = new Scene(group);
			
			primaryStage.setScene(scene);
			primaryStage.setHeight(600);
			primaryStage.setWidth(675);		
			primaryStage.show();
	        }  

}
